﻿//-----------------------------------------------------------------------
// <copyright file="OtherUser.cs" company="AFS">
// Copyright (c) AFS. All rights reserved.
//
//    This file is part of Chatbox.
//
//    Chatbox is free software: you can redistribute it and/or modify
//    it under the terms of the GNU Lesser General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    any later version.
//
//    Chatbox is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//    GNU Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public License
//    along with Chatbox. If not, see http://www.gnu.org/copyleft/lesser.html
// </copyright>
//----------------------------------------------------------------------- 

namespace ChatBox.DomainObjects.XmlFeedObjects
{
    /// <summary>
    /// Another user logged into the site
    /// </summary>
    public class OtherUser
    {
        /// <summary>
        /// Gets or sets a value indicating whether the user is an administrator
        /// </summary>
        public bool Administrator { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the user is a content editor
        /// </summary>
        public bool ContentEditor { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the user is a Committer
        /// </summary>
        public bool Committer { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the user is a chat channel operator who can ban other users
        /// </summary>
        public bool ChannelOperator { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the user is a developer
        /// </summary>
        public bool Developer { get; set; }

        /// <summary>
        /// Gets or sets the experience point that the user has
        /// </summary>
        public int ExperiencePoints { get; set;  }

        /// <summary>
        /// Gets or sets a value indicating whether the user is banned
        /// </summary>
        public bool IsBanned { get; set; }

        /// <summary>
        /// Gets or sets the user link
        /// </summary>
        public Link User { get; set; }

        /// <summary>
        /// Gets the users name
        /// </summary>
        public string UserName
        {
            get
            {
                return this.User.Text;
            }
        }

        /// <summary>
        /// Gets a value indicating whether the user has any special status flag set
        /// </summary>
        public bool HasAnySpecialStatus
        {
            get
            {
                return this.Administrator || this.ChannelOperator || this.ContentEditor || this.Committer || this.Developer;
            }
        }

        /// <summary>
        /// Display for debug
        /// </summary>
        /// <returns>string representing the user</returns>
        public override string ToString()
        {
            return this.User.ToString();
        }

        /// <summary>
        /// Equality test
        /// </summary>
        /// <param name="obj">the object to test</param>
        /// <returns>true if they are equivalent</returns>
        public override bool Equals(object obj)
        {
            OtherUser otherUser = obj as OtherUser;
            if (otherUser == null)
            {
                return false;
            }

            return this.User.Equals(otherUser.User);
        }

        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>the hash code</returns>
        public override int GetHashCode()
        {
            return this.User.GetHashCode();
        }
    }
}
